﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public class GyroscopeFunc : ItemFunc
{
    // Start is called before the first frame update 
    CombinableItem item;
    public float Power;
    private float Strength;
    protected bool IfRight;

    public void OnEnable()
    {
        item = GetComponent<CombinableItem>();
    }

    public override void KeyOnInvoke()
    {
        base.KeyOnInvoke();
        //var torque = item.GetComponentInParent<Rigidbody2D>();
        var _Rigidbody = item.GetComponentInParent<Rigidbody2D>();
        if (IfRight == true)
        {
            Strength = - Power;
        }
        else
        {
            Strength = Power;
        }
        _Rigidbody.AddTorque(Strength);
    }

    public override void KeyUpInvoke()
    {
        base.KeyUpInvoke();
    }
}
